Skip to main content

Machine Learning : Classifier / Logistic Regression Archive - machinelearningtechnilesh

 Machine Learning : Classifier / Logistic Regression ( part 5 )

We were learn all the stuff regrading the Machine learning . 
For Video Lecture on Machine Learning : Decision Go at bottom or google codewithnilesh
Logistic Regression actually is Classifier which is used to classify the data in two part i.e. Binary devision like True and False . One Region Contain the All predicted True Values and other contained the Flase predicted values .The Line which Seprate the region is called Boundary of Logistic Regression.
Machine learning : Classfier , Logistic Regression Archive - bytecode.technilesh.com

The Linear Regressor Equation is 
log(Y / Y -1 ) = b0 + b1 * X1 + b2 * X2 + b2 * X2 + b2 * X2



Step 1 : Data Preprocessing :


Initially Import all Libraries like Pandas , numpy , matlibplot pyplot & Sklearn
using the pandas take data and classify in to dependent and independent variable.

Code : 

#it classify the dasts using function who will  through ads suv car
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd


#import the data sets
dataset = pd.read_csv('Social_Network_Ads.csv')
X = dataset.iloc[: , [2,3]].values# which coloumwant to use to predict the result
Y = dataset.iloc[: ,:4].values

Code written by @Garry Raut

Step 2 : Split the data in Test and Train Set :

we used the Sklearns model selction Liberaries and Train_test_split class of this  

Split the data in X_train , X_test , Y_train , Y_test 

code :

#split the set to traning and test sets

from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size=0.2)
 # test size should be displayed


Step 3: Scaling the data for easy to classify :

For this Scaling we use the StandradScalar class from Library Sklearn . preprocessing.

Creating Object of class , SX object and using the fit method we will fit in the training and test set .Now we Scale the data.

 Step 4: Now we Logistic Regression : 


so for Logistic Regression we need the Logistic Class from the library sklearn . Linear model . we create object name ' Classifier  ' to acces the class and fit to the  model .Now we create an model .

Code:
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state=0)
# random state we get same result
classifier.fit(X_train,Y_train)
# fit the regession in train set
#prediction vector
Y_pred = classifier.predict(X_test)

step 5 : Confusion Matrix  :

This matrix is used to differentiate between  test result and Predicted result . so we idea of efficiency of model 

Code :

#Confusion matrix contanied te train set prediction 
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(Y_test,Y_pred)


Step 6 : Visualization of data



Code : 

#visulization data seprate
from matplotlib.colors import ListedColormap  
X_set, Y_set = X_train, Y_train  
X1, X2 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1stop =
 X_set[:, 0].max() + 1step  =0.01),  
np.arange(start = X_set[:, 1].min() - 1stop =
 X_set[:, 1].max() + 1step = 0.01))  
plt.contourf(X1, X2, classifier.predict(np.array
([X1.ravel(), X2.ravel()]).T).reshape(X1.shape),  
alpha = 0.75cmap = ListedColormap(('purple','green' )))
plt.xlim(X1.min(), X1.max())  
plt.ylim(X2.min(), X2.max())  
for i, j in enumerate(np.unique(Y_set)):  
    plt.scatter(X_set[Y_set == j, 0], X_set[Y_set == j, 1],  
        c = ListedColormap(('purple''green'))(i), label = j)  
plt.title('Logistic Regression CodeWithNilesh')  
plt.xlabel('CodeWithNilesh-Age')  
plt.ylabel('CodeWithNilesh-Salary')  
plt.legend()  
plt.show() 

Output : 

Machine learning : Classfier , Logistic Regression Archive - bytecode.technilesh.com



For Video Lecture on Machine Learning : Decision Go at bottom or google 
codewithnilesh



Comments

Popular posts from this blog

what gaming development require ,how the game developed ? -machinelearningtechnilesh

  What is gaming development & requirement? how the game developed? Hellos guys today we are exploring the video gaming industry and how the game is developed by the gaming engineers. The video gaming industry is growing exponentially on a large scale. A large no of games is launched by the many video gaming companies games like GTA 5 ( All series 1,2,3,4,5) by Rockstar studio & Cricket (2007,2010) by EA sports.The game development is also a big future for engineers. Today we are exploring the path to develop the game and which programming language is required and which skill do have to become a gaming developer.  Table Of Contents C# (C Sharp ) The best language for game development is c#. This language is similar to java and c,c++ programming. The Language is best because it used in AR & VR and ios development also. The best part of this programming language is the OOP (object-oriented programming) .this language works on .NET Frameworks. To build a game or AR ...

Sentiment Analysis using NLP Libraries -machinelearningtechnilesh

Doing Sentiment Analysis using NLP Libraries Conclusion from the Frist Approach : Sentiment Analysis using NLP Libraries (Unsupervised learning ) : result and analysis:  1) AFINN lexicon Model Performance metrics: ------------------------------ Accuracy: 0.71 Precision: 0.73 Recall: 0.71 F1 Score: 0.71 The Accuracy is 71% and F1 score tell about the performance of the that is 72%.that getting success is 72%. 2) SentiWordnet Model Performance metrics: ------------------------------ Accuracy: 0.69 Precision: 0.69 Recall: 0.69 F1 Score: 0.68 The Accuracy is 71% and F1 score tell about the performance of the that is 72%.that getting success is 72%. 3) VADER Model Performance metrics: ------------------------------ Accuracy: 0.71 Precision: 0.72 Recall: 0.71 F1 Score: 0.71 The Accuracy is 71% and F1 score tell about the performance of the that is 72%.that getting success is 72%. From comparing all three unsupervised model the AFFIN is best model because the precise value is greater than...

Computer Networks All Basic in one Blog :machinelearningtechnilesh

 . A computer network is formed by two or more devices connected together, these devices might be connected to share data to do some computations together or to share the resources. For example, a simple network where two computers are connected and one printer is connected and these both computers want to give command to the printer. So Resource Sharing is happening Do you do computer networks, computer networks are in fact everywhere they are in our office, they are in our home. In home, we might have multiple devices like laptops, Alexa, or other devices which are connected in a network. in office, you often see networks, your computers connected through a switch or any other device like router, and they form a network. So there are many, many networks that exist. In this course, we are going to focus mainly on internet, the largest network, almost half of the world's population is connected to the internet. In fact, most of our home devices, our office devices, they are connect...